﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>商品信息</title>
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="~/Content/jquery-easyui-1.4.2/demo.css">
    <link href="~/Content/Styles/Order.css" rel="stylesheet" />
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.2/jquery.min.js"></script>
    <script type="text/javascript" src="~/Content/jquery-easyui-1.4.2/jquery.easyui.min.js"></script>
    <script src="~/Content/jquery-easyui-1.4.2/locale/easyui-lang-zh_CN.js"></script>
    <link href="~/Content/Script/jquery.Jcrop.css" rel="stylesheet" />
    <script src="~/Content/jquery-easyui-1.4.2/jquery.Jcrop.js"></script>
    <script src="~/Content/layui/layui.js"></script>
    <link href="~/Content/layui/css/layui.css" rel="stylesheet" />

    @*KindEditor富文本编辑器*@
    <script src="~/Content/kindeditor/kindeditor-all.js"></script>
    <script src="~/Content/kindeditor/kindeditor-all-min.js"></script>
    <link href="~/Content/kindeditor/themes/default/default.css" rel="stylesheet" />
    <script src="~/Content/kindeditor/lang/zh-CN.js"></script>

    <script>
        var DishesSummary_editor;
        var DishesParam_editor;
        $(function () {
            //GetMer();//加载操作员管理的所有商户
            initTable();
            GetOrderType();
            //$('#btndetail').linkbutton('disable');
            //$('#btnadd').linkbutton('disable');
            //$('#btnedit').linkbutton('disable');
            //$('#btndell').linkbutton('disable');
            document.getElementById("dishesID_pic").style.display = "none";
            $('#xianshiPic').dialog({
                onClose: function () {
                    $("#fileDiv").remove();
                    $("#tp1Div").remove();
                    $("#picwenjian1").hide();
                }
            });
            var date;
            var merid;

            KindEditor.ready(function (K) {
                DishesSummary_editor = K.create('#DishesSummary_content', {
                    uploadJson: '../Content/kindeditor/asp.net/upload_json.ashx',
                    fileManagerJson: '../Content/kindeditor/asp.net/file_manager_json.ashx',
                    allowFileManager: true,
                    allowImageUpload: false, //上传图片框本地上传的功能，false为隐藏，默认为true
                    allowImageRemote: true, //上传图片框网络图片的功能，false为隐藏，默认为true
                    allowFileManager: true, //浏览图片空间
                    filterMode: false, //HTML特殊代码过滤
                });
            });

            KindEditor.ready(function (K) {
                DishesParam_editor = K.create('#DishesParam_content', {
                    uploadJson: '../Content/kindeditor/asp.net/upload_json.ashx',
                    fileManagerJson: '../Content/kindeditor/asp.net/file_manager_json.ashx',
                    allowFileManager: true,
                    allowImageUpload: false, //上传图片框本地上传的功能，false为隐藏，默认为true
                    allowImageRemote: true, //上传图片框网络图片的功能，false为隐藏，默认为true
                    allowFileManager: true, //浏览图片空间
                    filterMode: false, //HTML特殊代码过滤
                });
            });
        });

        var Mer;//商户ID
        var diplayText;//商户名称
        var filePath = "";//大图片路径
        var SmallfilePath = "";//小图片路径
        //获取商户
        function GetMer() {
            var grid = $('#SearchMer').combogrid({
                panelWidth: 500,
                idField: 'MerID',
                textField: 'MerName',
                url: '/Order_Dishes/getMer',
                method: 'post',
                pageSize: 5,
                pageList: [5],
                pagination: true,
                rownumbers: true,
                fitColumns: true,
                columns: [[
                    { field: 'MerID', title: '商户ID', width: 80, align: 'center' },
                    { field: 'MerName', title: '商户名称', width: 80, align: 'center' },
                    { field: 'MerTxt', title: '商户介绍', width: 120, align: 'center' },
                    { field: 'MerAdr', title: '商户地址', width: 80, align: 'center' },
                    { field: 'MerCall', title: '商户联系电话', width: 80, align: 'center' }
                ]],
                onSelect: function (index, row) {
                    diplayText = row[grid.combogrid('options').textField];
                    Mer = $('#SearchMer').combogrid("getValue");//获取操作员
                    //加载对应的商品
                    initTable(Mer);
                    //加载对应的商品分类
                    GetOrderType(Mer); // 查询
                    GetOrderType1(Mer); //新增
                    //控制增删查改的权限
                    $.post("/Order_Dishes/getPower", function (database) {
                        if (database != "") {
                            $('#btndetail').linkbutton('enable');
                            if (database.Add == 1) {
                                $('#btnadd').linkbutton('enable');
                            }
                            if (database.Dell == 1) {
                                $('#btndell').linkbutton('enable');
                            }
                            if (database.Edit == 1) {
                                $('#btnedit').linkbutton('enable');
                            }
                        }
                    })
                },
                onLoadSuccess: function () {
                    //分页后判断下是否有选中的数据行，combogrid会依据上一次选中的值进行初始化，选中datagrid数据行和设置显示值
                    if (!grid.combogrid('grid').datagrid('getSelected'))//不在当前页
                    {
                        $('#SearchMer').combogrid("setValue", diplayText);
                    }
                }
            });
        }

        //初始化表格 获取所有商品
        function initTable() {
            $('#View').datagrid({
                iconCls: 'icon-user',
                loadMsg: '数据加载中...',
                fitColumns: true,
                checkbox: true,
                checkOnSelect: true,
                selectOnCheck: true,
                nowrap: true,
                autoRowHeight: true,
                striped: true,
                url: '/Order_Dishes/getgrids',
                sortName: 'DishesID',
                sortOrder: 'desc',
                border: true,
                remoteSort: false,
                idField: 'DishesID',
                pageSize: 20,
                pagination: true,
                rownumbers: true,
                columns: [[
                    { field: 'IsCheck', title: '是否选择', width: 50, align: 'center', checkbox: true },
                    { field: 'DishesID', title: 'ID', sortable: true, hidden: true },
                    { field: 'DishesNmae', title: '商品名称', sortable: true },
                    {
                        field: 'DishesID2', title: '操作', sortable: true, align: 'center', formatter: function (value, row) {
                            return '<a href="#" onclick="downloadPic(' + row.DishesID + ')">上传照片</a>' + '&nbsp;&nbsp;&nbsp;' + '<a href="#" onclick="downloadDishesPic(' + row.DishesID + ')">轮播图</a>' + '&nbsp;&nbsp;&nbsp;' + '<a href="#" onclick="DishesPicManage(' + row.DishesID + ')">图片管理</a>'
                        }
                    },
                    { field: 'DishesTypeID_One', title: '一级分类ID', hidden: true },
                    { field: 'DishesTypeName_One', title: '一级分类名称', sortable: true },
                    { field: 'DishesTypeID', title: '二级分类ID', hidden: true },
                    { field: 'DishesTypeName', title: '二级分类名称', sortable: true },
                    {
                        field: 'DishesTypeState', title: '商品标志', formatter: function (value) {
                            if (value == "0") {
                                return '<span style="color: red;">已下架</span>'
                            } else {
                                return "已上架"
                            }
                        }
                    },
                    { field: 'DishesMon', title: '商品原价' },
                    { field: 'DishesPay', title: '商品实价' },
                    { field: 'DelPackMon', title: '包装费用' },
                    { field: 'BarCode', title: '商品条形码', width: 150 },
                    { field: 'DishesVol', title: '菜品销量' },
                    { field: 'DishesEvaNun', title: '评价次数', sortable: true },
                    { field: 'DishesEvaTxt', title: '留言次数', sortable: true },
                    { field: 'DishesEvaX', title: '总星数', sortable: true },
                    { field: 'DishesGood', title: '总推荐数', sortable: true },
                    {
                        field: 'DishesEnableInt', title: '是否参与积分', formatter: function (value) {
                            if (value == "0") {
                                return "否"
                            } else {
                                return "是"
                            }
                        }
                    },
                    {
                        field: 'DishesIsInt', title: '是否允许积分消费', formatter: function (value) {
                            if (value == "0") {
                                return "否"
                            } else {
                                return "是"
                            }
                        }
                    },
                    { field: 'DishesTxt', title: '菜品描述', width: '200px' },
                    {
                        field: 'DishesSummary', title: '菜品概述', width: '200px', formatter: function (value) {
                            if (value != null) {
                                return value.replace(/</g, '≮').replace(/>/g, '≯').replace(/&#xa;/g, '↓');
                            } else {
                                return null
                            }
                        }
                    },
                    {
                        field: 'DishesParam', title: '菜品参数', width: '200px', formatter: function (value) {
                            if (value != null) {
                                return value.replace(/</g, '≮').replace(/>/g, '≯').replace(/&#xa;/g, '↓');
                            } else {
                                return null
                            }
                        }
                    },
                    { field: 'DishesPic', title: '菜品照片', hidden: true },
                    { field: 'IntBZ', title: '备注' },
                ]],
                toolbar: '#tb1',
                onLoadSuccess: function (data) {
                    if (data) {
                        $.each(data.rows, function (index, item) {
                            if (item.IsCheck) {
                                $('#View').datagrid('checkRow', index);
                            } else {
                                $('#View').datagrid('uncheckRow', index);
                            }
                        });
                    }
                }
            });
        }

        //获取该商户图片
        function downloadPic(DishesID) {
            $("#dishesID_pic").text(DishesID);
            $("#fileToUpload").val("");
            //$("#uploadFile").hide();
            //$.get("/Order_Dishes/getDishePhoto?DisheID=" + DishesID, function (data) {
            //    $("#div_img").attr("src", data);
            //    $("#UploadPic").dialog("open").dialog("setTitle", "上传图片");
            //})
            $("#tishiyu").html("当前图片");
            //$("#tp1").attr("src", "");
            var file = "<div id=\"tp1Div\"  align=\"center\" style=\"margin:auto;width:300px;padding: 10px;\"><img id=\"tp1\" style=\"border-style:solid; border-width:1px; border-color:#000;\" src=\"\" /></div>"
                + "<div id=\"fileDiv\" align=\"center\" style=\"padding: 10px;\"><input  id=\"f\" onchange=\"imgFun(this.id, this.value, this.files)\" type=\"file\" /></div>";

            //$.post("/Order_Dishes/Image?id=" + DishesID, function (src) {
            //    gaib(src);
            //})
            $.get("/Order_Dishes/getDishePhoto?DisheID=" + DishesID, function (data) {
                //console.log(data);
                //var myDate = new Date();
                //var shij = myDate.getTime();
                $("#tp1").attr("src", data);
                //    $("#UploadPic").dialog("open").dialog("setTitle", "上传图片");
            });
            $("#picwenjian").prepend(file);
            $("#xianshiPic").dialog("open");
        };

        function gaib(c) {
            setTimeout(function () {
                var xsb = c.split('\\')[3];
                var xsb2 = c.split('\\')[4];
                var myDate = new Date();
                var shij = myDate.getTime();
                $("#tp1").attr("src", "/" + xsb + "/" + xsb2 + "?" + shij);
            }, 500)

        }

        //裁剪图片
        function imgFun(id, value, fi) {
            $("#picwenjian1").show()
            $("#tishiyu").html("请选择要上传的部分");
            //var wenjianTP = fi[0];
            //var fd = new FormData();
            //var xhr = new XMLHttpRequest();
            //fd.append("fileToUpload", wenjianTP);
            //fd.append("merid", $("#dishesID_pic").text());
            //xhr.open("POST", "/Order_Dishes/ToLead");
            //xhr.send(fd);
            var fielObj = document.getElementById(id)
            var aa = value;
            if (aa.match(/.jpg|.gif|.png|.bmp/i)) {
                //console.log(1);
            }
            var fiel = fi[0];
            //console.log(fiel);
            //console.log(fielObj);
            var img1 = document.getElementById("tp1")
            //var img2 = document.getElementById("tp2")
            var windowURL = window.URL || window.webkitURL;
            //console.log(windowURL);
            var dataURL = windowURL.createObjectURL(fi[0]);
            img1.src = dataURL;
            //img2.src = dataURL;
            //console.log(img1.src);
            $('#tp1').Jcrop({
                bgFade: true,
                onSelect: updatePreview,
                //onSelect: gaib,
                aspectRatio: 1.3,
                //allowSelect: false,
                //allowResize: false,
                //maxSize: [120, 120],
                minSize: [230, 230],
                boxWidth: 320,
                //boxHeight:350,
                getScaleFactor: [700, 300],
                setSelect: [230, 230, 0, 0],

            });
            //console.log("hi");

        };

        function updatePreview(c) {
            wenjian = document.getElementById('f').files[0].name;
            date = {
                x: Math.ceil(c.x),
                y: Math.ceil(c.y),
                w: Math.ceil(c.w),
                h: Math.ceil(c.h),
                pw: Math.ceil($('#tp1').width()),
                ph: Math.ceil($('#tp1').height()),
                t: wenjian,
                id: $("#dishesID_pic").text(),
            };
            //console.log(date);
        };

        //确定图片
        function quedPic() {
            var picname = document.getElementById('f').files[0];
            var fd = new FormData();
            var xhr = new XMLHttpRequest();
            fd.append("fileToUpload", picname);
            fd.append("id", $("#dishesID_pic").text());
            xhr.open("POST", "/Order_Dishes/ToLead");
            xhr.send(fd);
            setTimeout(function () {
                if (date.w >= 230 || date.h >= 230) {
                    $.post("/Order_Dishes/SaveImg", date, function (da) {
                        if (da = 1) {
                            uploadFile(date.t);
                        };
                    });
                } else {
                    alert("请选择图片进行裁剪");
                }
            }, 200);

        };

        //添加商品信息对话框
        function AddDialog() {
            filePath = "";
            $('#editDialog').dialog('open').dialog('setTitle', '新增商品');
            ClearText();
            ControllerEnable();
            GetOrderType1();
            document.getElementById("ok").style.display = "block";
            document.getElementById("addnone").style.display = "none";
            document.getElementById("addnone1").style.display = "none";
            document.getElementById("DishesID_None").style.display = "table-column";
        }

        //修改商品信息对话框
        function UpdateDialog() {
            filePath = "";
            var UpdateInfoID = $("#View").datagrid("getSelections");
            if (UpdateInfoID.length == 1) {
                $("#editDialog").dialog("open").dialog("setTitle", "修改商品信息");
                BingUpdate();
                ControllerEnable();
                $("#DishesTypeID2").combobox('disable');
                $("#DishesTypeID3").combobox('disable');
                document.getElementById("ok").style.display = "block";
                document.getElementById("DishesID_None").style.display = "block";
            }
            else {
                $.messager.alert("友情提示", "每次只能修改一行数据，你已经选择了<font color='red' size='6'>" + UpdateInfoID.length + "</font>行");
            }
        }

        //删除商品信息对话框
        function DeleteDialog() {
            //获取到商品分类ID
            //首先获取选中的商品分类的所有信息
            var objs = $("#View").datagrid("getChecked");//获取整行数据
            var DishesID = "";
            if (objs.length > 1) {
                $.each(objs, function (index, item) {
                    DishesID = DishesID + "," + item.DishesID;
                });
                //商品批量删除
                $.messager.confirm("商品删除信息", "您确认要删除这<font color='Red' size='3'>" + objs.length + "</font>个商品吗？", function (Del) {
                    if (Del) {
                        $.post("/Order_Dishes/UpdateOrder_Dishes_Del?DishesID=" + DishesID, function (date) {
                            if (date == "1") {
                                $.messager.alert("友情提示", "删除成功");
                                //清空原有数据
                                var item = $('#View').datagrid('getRows');
                                if (item) {
                                    for (var i = item.length - 1; i >= 0; i--) {
                                        var index = $('#View').datagrid('getRowIndex', item[i]);
                                        $('#View').datagrid('deleteRow', index);
                                    }
                                }
                                $('#View').datagrid('loadData', { total: 0, rows: [] });
                                initTable();
                                //$("#View").datagrid('reload');
                            }
                            else {
                                $.messager.alert("友情提示", "删除商品信息失败：" + date);
                            }
                        });
                    }
                });
            }
            else {
                var checkdata = $("#View").datagrid("getSelections");//获取整行数据
                if (checkdata.length == 1) {
                    var checkdata = $("#View").datagrid("getSelections")[0];//获取整行数据
                    //console.log($("#DishesSummary").textbox('getValue'));
                    //console.log($("#DishesPic").textbox('getValue'));
                    var postdata = {
                        DishesID: checkdata.DishesID,
                        DishesName: checkdata.DishesName,
                        MerID: Mer,
                        DishesTypeID: checkdata.DishesTypeID,
                        DishesEnableInt: checkdata.DishesEnableInt,
                        DishesIsInt: checkdata.DishesIsInt,
                        DishesMon: checkdata.DishesMon,
                        DelPackMon: checkdata.DelPackMon,
                        DishesPay: checkdata.DishesPay,
                        DishesVol: checkdata.DishesVol,
                        DishesTxt: checkdata.DishesTxt,
                        DishesSummary: checkdata.DishesSummary.replace(/</g, '≮').replace(/>/g, '≯').replace(/&#xa;/g, '↓'),
                        DishesParam: checkdata.DishesParam.replace(/</g, '≮').replace(/>/g, '≯').replace(/&#xa;/g, '↓'),
                        DishesPic: checkdata.DishesPic,
                        IntBZ: checkdata.IntBZ,
                        BarCode: checkdata.BarCode,
                    };
                    //console.log(postdata);
                    //发送异步请求删除数据
                    $.messager.confirm("商品删除信息", "您确认删除<font color='Red' size='3'>" + checkdata.DishesNmae + "</font>这个商品吗？", function (Del) {
                        if (Del) {
                            $.post("/Order_Dishes/UpdateOrder_Dishes?Tag=" + 3, postdata, function (data) {
                                if (data == "1") {
                                    $.messager.alert("友情提示", "删除成功");
                                    //清空原有数据
                                    var item = $('#View').datagrid('getRows');
                                    if (item) {
                                        for (var i = item.length - 1; i >= 0; i--) {
                                            var index = $('#View').datagrid('getRowIndex', item[i]);
                                            $('#View').datagrid('deleteRow', index);
                                        }
                                    }
                                    $('#View').datagrid('loadData', { total: 0, rows: [] });
                                    initTable();
                                    //$("#View").datagrid('reload');
                                }
                                else {
                                    $.messager.alert("友情提示", "删除失败:" + data);
                                }
                            });
                        }
                    });
                }
            }
        }

        //商品信息上架对话框
        function UpDialog() {
            //获取到商品分类ID
            //首先获取选中的商品分类的所有信息
            var objs = $("#View").datagrid("getChecked");//获取整行数据
            var DishesID = "";
            if (objs.length > 1) {
                $.each(objs, function (index, item) {
                    DishesID = DishesID + "," + item.DishesID;
                });
                //商品批量上架
                $.messager.confirm("商品上架信息", "您确认要上架这<font color='Red' size='3'>" + objs.length + "</font>个商品吗？", function (Up) {
                    if (Up) {
                        $.post("/Order_Dishes/UpdateOrder_Dishes_Up?DishesID=" + DishesID, function (data) {
                            if (data == "1") {
                                $.messager.alert("友情提示", "上架成功");
                                //initTable();
                                $("#View").datagrid('reload');
                            }
                            else {
                                $.messager.alert("友情提示", "上架失败" + date);
                            }
                        });
                    }
                });
            }
            else {
                var checkdata = $("#View").datagrid("getSelections");//获取整行数据
                if (checkdata.length == 1) {
                    var checkdata = $("#View").datagrid("getSelections")[0];//获取整行数据
                    //console.log($("#DishesSummary").textbox('getValue'));
                    //console.log($("#DishesPic").textbox('getValue'));
                    var postdata = {
                        DishesID: checkdata.DishesID,
                        DishesName: checkdata.DishesName,
                        MerID: Mer,
                        DishesTypeID: checkdata.DishesTypeID,
                        DishesEnableInt: checkdata.DishesEnableInt,
                        DishesIsInt: checkdata.DishesIsInt,
                        DishesMon: checkdata.DishesMon,
                        DelPackMon: checkdata.DelPackMon,
                        DishesPay: checkdata.DishesPay,
                        DishesVol: checkdata.DishesVol,
                        DishesTxt: checkdata.DishesTxt,
                        DishesSummary: checkdata.DishesSummary.replace(/</g, '≮').replace(/>/g, '≯').replace(/&#xa;/g, '↓'),
                        DishesParam: checkdata.DishesParam.replace(/</g, '≮').replace(/>/g, '≯').replace(/&#xa;/g, '↓'),
                        DishesPic: checkdata.DishesPic,
                        IntBZ: checkdata.IntBZ,
                        BarCode: checkdata.BarCode,
                    };
                    //console.log(postdata);
                    //发送异步请求上架商品
                    $.messager.confirm("商品上架信息", "您确认要上架<font color='Red' size='3'>" + checkdata.DishesNmae + "</font>这个商品吗？", function (Up) {
                        if (Up) {
                            $.post("/Order_Dishes/UpdateOrder_Dishes?Tag=" + 4, postdata, function (data) {
                                if (data == "1") {
                                    $.messager.alert("友情提示", "上架成功");
                                    //initTable(Mer);
                                    $("#View").datagrid('reload');
                                }
                                else {
                                    $.messager.alert("友情提示", "上架失败:" + data);
                                }
                            });
                        }
                    });
                }
            }
        }

        //商品信息下架对话框
        function DownDialog() {
            //获取到商品分类ID
            //首先获取选中的商品分类的所有信息
            var objs = $("#View").datagrid("getChecked");//获取整行数据
            var DishesID = "";
            if (objs.length > 1) {
                $.each(objs, function (index, item) {
                    DishesID = DishesID + "," + item.DishesID;
                });
                //商品批量下架
                $.messager.confirm("商品上架信息", "您确认要下架这<font color='Red' size='3'>" + objs.length + "</font>个商品吗？", function (Down) {
                    if (Down) {
                        $.post("/Order_Dishes/UpdateOrder_Dishes_Down?DishesID=" + DishesID, function (data) {
                            if (data == "1") {
                                $.messager.alert("友情提示", "下架成功");
                                //initTable();
                                $("#View").datagrid('reload');
                            }
                            else {
                                $.messager.alert("友情提示", "下架失败" + date);
                            }
                        });
                    }
                });
            }
            else {
                var checkdata = $("#View").datagrid("getSelections");//获取整行数据
                if (checkdata.length == 1) {
                    var checkdata = $("#View").datagrid("getSelections")[0];//获取整行数据
                    //console.log($("#DishesSummary").textbox('getValue'));
                    //console.log($("#DishesPic").textbox('getValue'));
                    var postdata = {
                        DishesID: checkdata.DishesID,
                        DishesName: checkdata.DishesName,
                        MerID: Mer,
                        DishesTypeID: checkdata.DishesTypeID,
                        DishesEnableInt: checkdata.DishesEnableInt,
                        DishesIsInt: checkdata.DishesIsInt,
                        DishesMon: checkdata.DishesMon,
                        DelPackMon: checkdata.DelPackMon,
                        DishesPay: checkdata.DishesPay,
                        DishesVol: checkdata.DishesVol,
                        DishesTxt: checkdata.DishesTxt,
                        DishesSummary: checkdata.DishesSummary.replace(/</g, '≮').replace(/>/g, '≯').replace(/&#xa;/g, '↓'),
                        DishesParam: checkdata.DishesParam.replace(/</g, '≮').replace(/>/g, '≯').replace(/&#xa;/g, '↓'),
                        DishesPic: checkdata.DishesPic,
                        IntBZ: checkdata.IntBZ,
                        BarCode: checkdata.BarCode,
                    };
                    //console.log(postdata);
                    //发送异步请求下架商品
                    $.messager.confirm("商品下架信息", "您确认要下架<font color='Red' size='3'>" + checkdata.DishesNmae + "</font>这个商品吗？", function (Down) {
                        if (Down) {
                            $.post("/Order_Dishes/UpdateOrder_Dishes?Tag=" + 5, postdata, function (data) {
                                if (data == "1") {
                                    $.messager.alert("友情提示", "下架成功");
                                    //initTable(Mer);
                                    $("#View").datagrid('reload');
                                }
                                else {
                                    $.messager.alert("友情提示", "下架失败:" + data);
                                }
                            });
                        }
                    });
                }
            }
        }

        //商品信息明细对话话框
        function DetailDialog() {
            var UpdateInfoID = $("#View").datagrid("getSelections");
            if (UpdateInfoID.length == 1) {
                $("#editDialog").dialog("open").dialog("setTitle", "商品信息明细");
                BingUpdate();
                $('input,select,textarea', $('form[id="editController"]')).prop('readonly', true);
                $("#DishesTypeID2").combobox('disable');
                $("#DishesTypeID3").combobox('disable');
                $("#DishesEnableInt").combobox('disable');
                $("#DishesIsInt").combobox('disable');
                document.getElementById("ok").style.display = "none";
                document.getElementById("DishesID_None").style.display = "block";
            }
            else {
                $.messager.alert("友情提示", "每次只能查看一行数据，你已经选择了<font color='red' size='6'>" + UpdateInfoID.length + "</font>行");
            }
        }

        //获取修改商品信息
        function BingUpdate() {
            //首先获取选中的商品信息
            var checkdata = $("#View").datagrid("getSelections")[0];

            if (checkdata.DishesTypeID != null) {
                $.get("/Order_Dishes/getOrderTypesByDishesTypeID?DishesTypeID=" + checkdata.DishesTypeID, function (database) {
                    $("#DishesTypeID2").combobox('setValue', database[0].DishesTypeName) //菜品一级分类名称

                    $.get("/Order_Dishes/getOrderTypesByPantID?PantID=" + checkdata.DishesTypeID, function (database) {
                        $("#DishesTypeID3").combobox('setValue', database[0].DishesTypeName)    //菜品二级分类名称
                    })
                })
            }

            if (checkdata != null) {
                $("#DishesID").html(checkdata.DishesID)  //菜品id
                $("#DishesNmae").textbox('setValue', checkdata.DishesNmae)  //菜品名称
                $("#DishesTypeID").combobox('setValue', checkdata.DishesTypeID) //菜品二级分类id
                $("#DishesEnableInt").combobox('setValue', checkdata.DishesEnableInt)  //菜品是否允许积分
                $("#DishesIsInt").combobox('setValue', checkdata.DishesIsInt);  //是否积分消费
                $("#DishesMon").numberbox('setValue', checkdata.DishesMon); //菜原价
                $("#DelPackMon").numberbox('setValue', checkdata.DelPackMon); //包装费用
                $("#DishesPay").numberbox('setValue', checkdata.DishesPay); // 实际价格
                $("#DishesVol").textbox('setValue', checkdata.DishesVol); //实际销量
                document.getElementById("div_img").src = checkdata.DishesPic;
                filePath = checkdata.DishesPic;
                SmallfilePath = checkdata.DishesPic;
                $("#DishesTxt").val(checkdata.DishesTxt);   //菜品描述
                KindEditor.html('#DishesSummary_content', checkdata.DishesSummary);
                //$("#DishesSummary").val('setValue', checkdata.DishesSummary)  //菜品概述
                KindEditor.html('#DishesParam_content', checkdata.DishesParam);
                //$("#DishesParam").textbox('setValue', checkdata.DishesParam)  //菜品参数
                $("#DishesEvaNun").textbox('setValue', checkdata.DishesEvaNun);  //菜品被评价次数
                $("#DishesEvaTxt").textbox('setValue', checkdata.DishesEvaTxt); //菜品被留言次数
                $("#DishesGood").textbox('setValue', checkdata.DishesGood);  //菜品被推荐次数
                $("#IntBZ").val(checkdata.IntBZ); //备注
                $("#BarCode").textbox('setValue', checkdata.BarCode);   //条形码
            }
            //console.log(checkdata);
        }

        //控件控制
        function ControllerEnable() {
            $('input,select,textarea', $('form[id="editController"]')).prop('readonly', false);
            $("#DishesVol").textbox('readonly', true);
            $("#DishesEvaTxt").textbox('readonly', true);
            $("#DishesEvaNun").textbox('readonly', true);
            $("#DishesGood").textbox('readonly', true);
            $("#DishesTypeID2").combobox('enable');
            $("#DishesEnableInt").combobox('enable');
            $("#DishesIsInt").combobox('enable');
        }

        //根据商品名称和商品分类检索商品
        function SearchDishes() {
            var DishesType = $('#DishesType').combobox('getValue');
            var DishesType2 = $('#DishesType2').combobox('getValue');
            var DishesName = $('#SearchDishes').textbox('getValue');

            if (DishesType == '-8989') {
                initTable();
                return false;
            }
            $('#View').datagrid({
                url: '/Order_Dishes/searchDishes?DishesType=' + DishesType + "&DishesType2=" + DishesType2 + "&DishesName=" + DishesName,
            });
        }

        //获取商品分类-查询
        function GetOrderType() {
            //$.get("/Order_Dishes/getOrderTypesBySearch", {}, function (database) {
            //    var a = {
            //        "DishesTypeID": "-8989",
            //        "DishesTypeName": "全部",
            //    }
            //    //database.push(a)
            //    database.splice(0, 0, a); // 将全部的选项放在最前
            //    $('#DishesType').combobox({
            //        valueField: 'DishesTypeID',
            //        textField: 'DishesTypeName',
            //        value: '-8989',
            //        text: '全部',
            //        data: database,
            //    });
            //})

            var DishesType = $('#DishesType').combobox({
                url: '/Order_Dishes/getOrderTypes',
                //editable: false,
                valueField: 'DishesTypeID',
                textField: 'DishesTypeName',
                onSelect: function (record) {
                    //刷新数据，重新读取一级分类下的二级分类，并清空当前输入的值
                    DishesType2.combobox({
                        disabled: false,
                        url: "/Order_Dishes/getOrderTypess?DishesTypeID=" + record.DishesTypeID,
                        valueField: 'DishesTypeID',
                        textField: 'DishesTypeName',
                        value: '-8989',
                        text: '全部',
                    }).combobox('clear');
                }
            });
            var DishesType2 = $('#DishesType2').combobox({
                disabled: true,
                url: "/Order_Dishes/getOrderTypess?DishesTypeID=" + DishesType.val(),
                valueField: 'DishesTypeID',
                textField: 'DishesTypeName',
            });
        }

        //获取商品分类-新增
        function GetOrderType1() {
            //$.get("/Order_Dishes/getOrderTypes", {}, function (database) {
            //    //console.log(database);
            //    if (database != null) {
            //        $('#DishesTypeID').combobox(
            //            {
            //                valueField: 'DishesTypeID',
            //                textField: 'DishesTypeName',
            //                data: database
            //            })
            //    }
            //})

            //商品分类一二级联动
            var DishesTypeID2 = $('#DishesTypeID2').combobox({
                url: '/Order_Dishes/getOrderTypes',
                editable: false,
                valueField: 'DishesTypeID',
                textField: 'DishesTypeName',
                onSelect: function (record) {
                    //console.log(record);
                    //刷新数据，重新读取一级分类下的二级分类，并清空当前输入的值
                    DishesTypeID3.combobox({
                        disabled: false,
                        url: "/Order_Dishes/getOrderTypess?DishesTypeID=" + record.DishesTypeID,
                        valueField: 'DishesTypeID',
                        textField: 'DishesTypeName',
                        onSelect: function (reg) {
                            var DishesTypeID = reg.DishesTypeID;
                            $('#DishesTypeID').combobox('setValue', DishesTypeID);
                        }
                    }).combobox('clear');
                }
            });
            var DishesTypeID3 = $('#DishesTypeID3').combobox({
                disabled: true,
                url: "/Order_Dishes/getOrderTypess?DishesTypeID=" + DishesTypeID2.val(),
                valueField: 'DishesTypeID',
                textField: 'DishesTypeName',
            });
        }

        //查找图片
        function fileSelected(sourceId, targetId) {
            if (typeof FileReader == 'undefined') {
                $.messager.alert("温馨提示", "请选择图片");
                return;
            }
            var reader = new FileReader();
            reader.onload = function (e) {
                var img = document.getElementById(targetId);
                img.src = this.result;
            }
            reader.readAsDataURL(document.getElementById(sourceId).files[0]);
            var file = document.getElementById('fileToUpload').files[0];
            var fileName = file.name;
            var file_typename = fileName.substring(fileName.lastIndexOf('.'), fileName.length);
            //var url = ConfigurationManager.AppSettings["Photo"];
            filePath = "/Dishes/" + fileName;
            if (file_typename == '.jpg') {//这里限定上传文件文件类型
                if (file) {
                    //alert("显示上传")
                    $("#uploadFile").show();
                    var fileSize = 0;
                    if (file.size > 1024 * 1024) {
                        fileSize = (Math.round(file.size * 100 / (1024 * 1024)) / 100).toString() + 'MB';
                    }
                    else {
                        fileSize = (Math.round(file.size * 100 / 1024) / 100).toString() + 'KB';
                    }
                }
            } else {
                $("#uploadFile").hide();
                document.getElementById('fileName').innerHTML = "<span style='color:Red'>错误提示:上传文件应该是.jpg后缀而不应该是" + file_typename + ",请重新选择文件</span>"
                //document.getElementById('fileSize').innerHTML = "";
                //document.getElementById('fileType').innerHTML = "";
            }
        }

        //加载文件
        function uploadFile(name) {
            //var picname = document.getElementById('fileToUpload').files[0].name;
            var picname = name;
            var disheid = $("#dishesID_pic").text();
            $.get("/Order_Dishes/ToLoadPic?DisheID=" + disheid + "&PicName=" + picname, function (data) {
                if (data == "1") {
                    //$('#dlg_progress').dialog('open');
                    //var fd = new FormData();
                    //fd.append("fileToUpload", document.getElementById('fileToUpload').files[0]);
                    //var xhr = new XMLHttpRequest();
                    //xhr.upload.addEventListener("progress", uploadProgress, false);
                    //xhr.addEventListener("load", uploadComplete, false);
                    //xhr.addEventListener("error", uploadFailed, false);
                    //xhr.addEventListener("abort", uploadCanceled, false);
                    //xhr.open("POST", "/Order_Dishes/ToLead");
                    //xhr.send(fd);
                    //$('#dlg_progress').dialog('close');//关闭进度条
                    $('#xianshiPic').dialog('close');//关闭图片上传界面
                    $.messager.alert("友情提示", "上传成功！");
                    //window.location.href = "/Order_Dishes/index";
                    initTable();
                } else {
                    $.messager.alert("友情提示", "图片上传失败！");
                }
            });

        }

        //文件上传进程
        function uploadProgress(evt) {
            if (evt.lengthComputable) {
                var percentComplete = Math.round(evt.loaded * 100 / evt.total);
                $('#progressNumber').progressbar('setValue', percentComplete);

            }
            else {
                document.getElementById('progressNumber').innerHTML = '无法计算';
            }

            //$.messager.alert("友情提示", "上传成功！");
            //location.reload();
        }

        //加载异常
        function uploadComplete(evt) {
            /* 服务器返回数据*/
            var message = evt.target.responseText;
            //$.messager.alert(message);
            //location.reload();
        }

        //上传文件失败
        function uploadFailed(evt) {
            $.messager.alert("上传出错.");
        }

        //加载连接异常
        function uploadCanceled(evt) {
            $.messager.alert("上传已由用户或浏览器取消删除连接.");
        }

        //清空文本框中的值
        function ClearText() {
            $("#DishesID").html("");
            $("#DishesNmae").textbox('setValue', "");
            $("#DishesTypeID2").combobox('setValue', null);
            $("#DishesTypeID3").combobox('setValue', null);
            $("#DishesEnableInt").combobox('setValue', 0);
            $("#DishesIsInt").combobox('setValue', 0);
            $("#DishesMon").numberbox('setValue', 0);
            $("#DelPackMon").numberbox('setValue', 0);
            $("#DishesPay").numberbox('setValue', 0);
            $("#DishesVol").textbox('setValue', "");
            document.getElementById("div_img").src = "";
            $("#DishesTxt").val("");
            KindEditor.html("#DishesSummary_content", "");
            //$("#DishesSummary").textbox('setValue', "")
            KindEditor.html("#DishesParam_content", "");
            //$("#DishesParam").textbox('setValue', "")
            $("#IntBZ").val("");
            $("#DishesEvaNun").textbox('setValue', "");
            $("#DishesEvaTxt").textbox('setValue', "");
            $("#DishesGood").textbox('setValue', "");
            $("#BarCode").textbox('setValue', "");
        }

        //保存
        function submitForm() {
            //首先判断前台的验证是否通过
            var valid = $('#editController').form('validate');
            if (valid == false) {
                return false;
            }
            //var Summary_content = DishesSummary_editor.text();
            DishesSummary_editor.sync();
            Summary_content = document.getElementById('DishesSummary_content').value;//获取商品概述
            if (Summary_content) {
                Summary_content = Summary_content.replace(/</g, '≮').replace(/>/g, '≯').replace(/&#xa;/g, '↓');
            }
            //var Param_content = DishesParam_editor.text();
            DishesParam_editor.sync();
            Param_content = document.getElementById('DishesParam_content').value;//获取商品参数
            if (Param_content) {
                Param_content = Param_content.replace(/</g, '≮').replace(/>/g, '≯').replace(/&#xa;/g, '↓');
            }
            //console.log(Summary_content);
            //console.log(Param_content);
            var postdata = {
                DishesID: $("#DishesID").html(),
                DishesNmae: $("#DishesNmae").textbox('getValue'),
                DishesTypeID: $("#DishesTypeID").combobox('getValue'),
                DishesEnableInt: $("#DishesEnableInt").combobox('getValue'),
                DishesIsInt: $("#DishesIsInt").combobox('getValue'),
                DishesMon: $("#DishesMon").numberbox('getValue'),
                DelPackMon: $("#DelPackMon").numberbox('getValue'),
                DishesPay: $("#DishesPay").numberbox('getValue'),
                DishesTxt: $("#DishesTxt").val(),
                DishesSummary: Summary_content,
                DishesParam: Param_content,
                DishesPic: filePath,
                DishesPicSmall: SmallfilePath,
                IntBZ: $("#IntBZ").val(),
                BarCode: $("#BarCode").textbox('getValue'),
            };
            //console.log(postdata);
            var Tag = 1;
            if (postdata.DishesID != "") {
                Tag = 2;
            }
            if ($("#DishesNmae").textbox('getValue') == null || $("#DishesNmae").textbox('getValue') == "") {
                alert("商品名称需必填！");
            }
            else if ($("#DishesTypeID").combobox('getValue') == null || $("#DishesTypeID").combobox('getValue') == "" || $("#DishesTypeID2").combobox('getValue') == null || $("#DishesTypeID2").combobox('getValue') == "" || $("#DishesTypeID3").combobox('getValue') == null || $("#DishesTypeID3").combobox('getValue') == "") {
                alert("商品分类需必选！");
            }
            else if ($("#DishesMon").numberbox('getValue') == null || $("#DishesMon").numberbox('getValue') == "" || $("#DishesMon").numberbox('getValue') == 0) {
                alert("商品原价需必填！");
            }
            else if ($("#DishesPay").numberbox('getValue') == null || $("#DishesPay").numberbox('getValue') == "" || $("#DishesPay").numberbox('getValue') == 0) {
                alert("商品实价需必填！");
            }
            else if ($("#BarCode").textbox('getValue') == null || $("#BarCode").textbox('getValue') == "") {
                alert("商品条形码需必填！");
            }
            else if ($("#DishesTxt").val() == null || $("#DishesTxt").val() == "") {
                alert("商品描述需必填！");
            }
            else if (Summary_content == null || Summary_content == "") {
                alert("商品概述需必填！");
            }
            else if (Param_content == null || Param_content == "") {
                alert("商品参数需必填！");
            }
            else {
                //使用异步实现修改用户信息
                $.post("/Order_Dishes/UpdateOrder_Dishes?Tag=" + Tag, postdata, function (date) {
                    if (date == "1") {
                        if (Tag == 1) {
                            //$.messager.alert("提示", "添加成功");
                            $.messager.confirm('提示', "<font color='red' size='6'>添加成功</font> 是否重新添加商品？", function (Add) {
                                if (Add) {
                                    $("#editDialog").dialog('close');
                                    var DishesTypeID_Name = $("#DishesTypeID").combobox('getValue');
                                    var DishesTypeID2_Name = $("#DishesTypeID2").combobox('getText');
                                    var DishesTypeID3_Name = $("#DishesTypeID3").combobox('getText');
                                    AddDialog();
                                    $("#DishesTypeID").combobox('setValue', DishesTypeID_Name);     //菜品二级分类ID
                                    $("#DishesTypeID2").combobox('setValue', DishesTypeID2_Name);    //菜品一级分类名称
                                    $("#DishesTypeID3").combobox('setValue', DishesTypeID3_Name);    //菜品二级分类名称
                                    $("#View").datagrid('reload');
                                } else {
                                    $("#editDialog").dialog('close');
                                    $.messager.alert("提示", "添加成功");
                                    $("#View").datagrid('reload');
                                }
                            });
                        }
                        else {
                            $.messager.confirm('提示', "<font color='red' size='6'>修改成功</font> 是否重新添加商品？", function (Edit) {
                                if (Edit) {
                                    $("#editDialog").dialog('close');
                                    var DishesTypeID_Name = $("#DishesTypeID").combobox('getValue');
                                    var DishesTypeID2_Name = $("#DishesTypeID2").combobox('getValue');
                                    var DishesTypeID3_Name = $("#DishesTypeID3").combobox('getValue');
                                    AddDialog();
                                    $("#DishesTypeID").combobox('setValue', DishesTypeID_Name);     //菜品二级分类ID
                                    $("#DishesTypeID2").combobox('setValue', DishesTypeID2_Name);    //菜品一级分类名称
                                    $("#DishesTypeID3").combobox('setValue', DishesTypeID3_Name);    //菜品二级分类名称
                                    $("#View").datagrid('reload');
                                } else {
                                    $("#editDialog").dialog('close');
                                    $.messager.alert("提示", "修改成功");
                                    $("#View").datagrid('reload');
                                }
                            });
                        }
                    }
                    else {
                        $.messager.alert("友情提示", "修改失败，请检查");
                    }
                });
            }
        }

        //商品轮播多图上传
        function downloadDishesPic(DishesID_Img) {
            $("#upload_file_modal").dialog("open");
            GetAllOrder_DishesPhoto(DishesID_Img);

            layui.use(['layer', 'upload', 'element'], function () {
                var element = layui.element;
                var $ = layui.jquery, layer = layui.layer, upload = layui.upload;
                upload.render({
                    elem: '#ChoosePicture',
                    url: '/FileInfo/UploadPic?DishesID=' + DishesID_Img + '&FileType=' + 2,
                    multiple: true,
                    size: 4 * 1024,
                    exts: 'jpg|png|gif|bmp|jpeg',
                    choose: function (obj) {
                        layer.load();
                    },
                    done: function (result, index, upload) {
                        //console.log(result);
                        //上传完毕
                        layer.closeAll('loading');
                        if ((result.CarouselID && result.CarouselURL && result.CarouselName) != null) {
                            //$('#Picture').val(result);
                            //console.log(result.Data.FileURL.indexOf(".pdf"));
                            //console.log(result.Data.FileURL.indexOf("application/pdf"));
                            $('#picture-name').text('已成功上传图片  ' + result.CarouselName);
                            $('#PictureListDemo').append('<div id="' + result.CarouselID + '" class="imgDiv" style="width: 250px;height: 200px;float:left;padding:5px;"><a href="' + result.CarouselURL + '" target="_blank"><img src="' + result.CarouselURL + '" style="width:100%; height:100%;" /></a><img src="/Content/img/delete.png" class="delete" onclick="Delete(\'' + result.CarouselID + '\',\'' + 2 + '\')" /></div>');

                            $(".imgDiv").mouseenter(function () {
                                $(this).find(".delete").show();
                            });

                            $(".imgDiv").mouseleave(function () {
                                $(this).find(".delete").hide();
                            });
                            return;
                        } else {
                            $('#picture-name').text(result.Msg);
                            this.error(index, upload);
                        }
                    },
                    error: function (index, upload) {
                        layer.closeAll('loading');
                    }
                });
            });
        }

        //获取商品对应的轮播图片
        function GetAllOrder_DishesPhoto(DishesID_Img) {
            if (DishesID_Img != null) {
                document.getElementById('PictureListDemo').innerHTML = "" //把div里面的内容清空
                $('#picture-name').text("");
                $.post("/Order_Dishes/GetOrder_DishesCarousel_Photo?DishesID=" + DishesID_Img, function (date) {
                    //console.log(date);
                    if (date.length > 0 && date != 0) {
                        for (var i = 0; i < date.length; i++) {
                            $('#PictureListDemo').append('<div id="' + date[i].CarouselID + '" class="imgDiv" style="width: 250px;height: 200px;float:left;padding:5px;"><a href="' + date[i].CarouselURL + '" target="_blank"><img src="' + date[i].CarouselURL + '" style="width:100%; height:100%;" /></a><img src="/Content/img/delete.png" class="delete" onclick="Delete(\'' + date[i].CarouselID + '\',\'' + 2 + '\')" /></div>');
                        }

                        $(".imgDiv").mouseenter(function () {
                            $(this).find(".delete").show();
                        });

                        $(".imgDiv").mouseleave(function () {
                            $(this).find(".delete").hide();
                        });
                        return;
                    }
                });
            }
        }

        //图片管理多图上传
        function DishesPicManage(DishesID_ManageImg) {
            $("#upload_file_modal").dialog("open");
            GetAllOrder_DishesManagePhoto(DishesID_ManageImg);

            layui.use(['layer', 'upload', 'element'], function () {
                var element = layui.element;
                var $ = layui.jquery, layer = layui.layer, upload = layui.upload;

                upload.render({
                    elem: '#ChoosePicture',
                    url: '/FileInfo/UploadPic?DishesID=' + DishesID_ManageImg + '&FileType=' + 1,
                    multiple: true,
                    size: 4 * 1024,
                    exts: 'jpg|png|gif|bmp|jpeg',
                    choose: function (obj) {
                        layer.load();
                    },
                    done: function (result, index, upload) {
                        //上传完毕
                        layer.closeAll('loading');
                        if ((result.ParameterOverviewID && result.ParameterOverviewURL && result.ParameterOverviewName) != null) {
                            //$('#Picture').val(result);
                            //console.log(result.Data.FileURL.indexOf(".pdf"));
                            //console.log(result.Data.FileURL.indexOf("application/pdf"));
                            $('#picture-name').text('已成功上传图片  ' + result.ParameterOverviewName);
                            $('#PictureListDemo').append('<div id="' + result.ParameterOverviewID + '" class="imgDiv" style="width: 250px;height: 200px;float:left;padding:5px;"><a href="' + result.ParameterOverviewURL + '" target="_blank"><img src="' + result.ParameterOverviewURL + '" style="width:100%; height:100%;" /></a><img src="/Content/img/delete.png" class="delete" onclick="Delete(\'' + result.ParameterOverviewID + '\',\'' + 1 + '\')" /></div>');

                            $(".imgDiv").mouseenter(function () {
                                $(this).find(".delete").show();
                            });

                            $(".imgDiv").mouseleave(function () {
                                $(this).find(".delete").hide();
                            });
                            return;
                        } else {
                            $('#picture-name').text(result.Msg);
                            this.error(index, upload);
                        }
                    },
                    error: function (index, upload) {
                        layer.closeAll('loading');
                    }
                });
            });
        }

        //获取商品对应的商品概述、参数图片
        function GetAllOrder_DishesManagePhoto(DishesID_ManageImg) {
            if (DishesID_ManageImg != null) {
                document.getElementById('PictureListDemo').innerHTML = "" //把div里面的内容清空
                $('#picture-name').text("");
                $.post("/Order_Dishes/GetOrder_DishesParameterOverview_Photo?DishesID=" + DishesID_ManageImg, function (date) {
                    //console.log(date);
                    if (date.length > 0 && date != 0) {
                        for (var i = 0; i < date.length; i++) {
                            $('#PictureListDemo').append('<div id="' + date[i].ParameterOverviewID + '" class="imgDiv" style="width: 250px;height: 200px;float:left;padding:5px;"><a href="' + date[i].ParameterOverviewURL + '" target="_blank"><img src="' + date[i].ParameterOverviewURL + '" style="width:100%; height:100%;" /></a><img src="/Content/img/delete.png" class="delete" onclick="Delete(\'' + date[i].ParameterOverviewID + '\',\'' + 1 + '\')" /></div>');
                        }

                        $(".imgDiv").mouseenter(function () {
                            $(this).find(".delete").show();
                        });

                        $(".imgDiv").mouseleave(function () {
                            $(this).find(".delete").hide();
                        });
                        return;
                    }
                });
            }
        }

        //删除图片
        function Delete(FileInfoID, FileType) {
            $.messager.confirm("商品图片删除信息", "您确认要删除这这张图片吗？", function (Del) {
                if (Del) {
                    $.ajax({
                        type: 'post',
                        data: { FileInfoID: FileInfoID, FileType: FileType },
                        url: '/FileInfo/Photo_Delete',
                        success: function (result) {
                            if (result == 1) {
                                //删除成功
                                $.messager.alert("友情提示", "删除成功");
                                $("#" + FileInfoID).remove();
                                $('#picture-name').text("");
                            } else {
                                //发生错误，应弹框提示
                                $.messager.alert("友情提示", "删除失败" + result);
                            }
                        }
                    })
                }
            });
        }

        //图片上传关闭按钮
        function UploadfileImg() {
            $("#upload_file_modal").dialog("close");
            window.location.reload();
        }

    </script>

    <style>
        .dig-table {
            border: 0px solid black;
            line-height: 32px;
            width: 90%;
        }

        .box {
            position: fixed;
            width: 100%;
            height: 100%;
            background: rgba(0,0,0,0.2);
            display: none;
        }


        .imgDiv {
            display: inline-block;
            position: relative;
        }

            .imgDiv .delete {
                position: absolute;
                top: 8px;
                right: 8px;
                width: 30px;
                height: 30px;
                display: none;
            }

        td label {
            padding-left: 5px;
            color: red;
        }
    </style>
</head>
<body style="padding: 0">
    @*<div style="padding: 5px; background-color: #F4F4F4">
            <div>
                <a>商户：</a>
                <input id="SearchMer" class="easyui-combogrid" style="width: 120px" />
            </div>
        </div>*@

    <div>
        <table id="View" border="0"></table>
    </div>

    <div id="tb1" style="background-color: #F4F4F4">
        <div style="margin-bottom: 5px">
            <a href="#" id="btndetail" class="easyui-linkbutton" iconcls="icon-more" onclick="DetailDialog()" plain="true">明细</a>
            <a href="#" id="btnadd" class="easyui-linkbutton" iconcls="icon-add" onclick="AddDialog()" plain="true">新增</a>
            <a href="#" id="btnedit" class="easyui-linkbutton" iconcls="icon-edit" onclick="UpdateDialog()" plain="true">修改</a>
            <a href="#" id="btndell" class="easyui-linkbutton" iconcls="icon-cancel" onclick="DeleteDialog()" plain="true">删除</a>
            <a href="#" id="btnup" class="easyui-linkbutton" iconcls="icon-undo" onclick="UpDialog()" plain="true">上架</a>
            <a href="#" id="btndown" class="easyui-linkbutton" iconcls="icon-redo" onclick="DownDialog()" plain="true">下架</a>
        </div>
        <div style="margin-left: 5px;">
            <a>商品名称：</a>
            <input id="SearchDishes" class="easyui-textbox" style="width: 120px" />
            <a>商品分类：</a>
            <input id="DishesType" class="easyui-combobox" style="width: 120px" />
            <input id="DishesType2" class="easyui-combobox" style="width: 120px" />
            <a id="SearchBtn" href="#" class="easyui-linkbutton" onclick="SearchDishes()" data-options="iconCls:'icon-search'">检索</a>
        </div>
    </div>

    <div id="editDialog" class="easyui-dialog" class="easyui-dialog" style="width:1024px; padding: 10px; padding:fixed; top:5px;" closed="true" resizable="true" modal="true" buttons="#dlg-buttons" align="center">
        <form id="editController" method="post" novalidate="novalidate">
            @using (Html.BeginForm("ToLead", "PhotoManagerPro", FormMethod.Post, new { enctype = "multipart/form-data", id = "form1" }))
            {
                <table id="tbledit" class="dig-table">
                    <tr>
                        <td class="fr" id="DishesID_None">商品ID：</td>
                        <td>
                            <span id="DishesID" name="DishesID" style="color:red;"></span>
                        </td>
                        <td class="fr">商品名称：<label>*</label></td>
                        <td>
                            <input class="easyui-textbox" type="text" id="DishesNmae" name="DishesNmae" />
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">商品分类：<label>*</label></td>
                        <td hidden="hidden">
                            <input class="easyui-combobox" type="text" id="DishesTypeID" name="DishesTypeID" />
                        </td>
                        <td>
                            <input class="easyui-combobox" type="text" id="DishesTypeID2" name="DishesTypeID2" />
                            <input class="easyui-combobox" type="text" id="DishesTypeID3" name="DishesTypeID3" />
                        </td>
                        <td class="fr">商品原价：<label>*</label></td>
                        <td>
                            <input class="easyui-numberbox" type="text" id="DishesMon" name="DishesMon" data-options="min:0,precision:2" />&nbsp;元
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">商品实价：<label>*</label></td>
                        <td>
                            <input class="easyui-numberbox" data-options="min:0,precision:2" type="text" id="DishesPay" name="DishesPay" />&nbsp;元
                        </td>
                        <td class="fr">包装费用：</td>
                        <td>
                            <input class="easyui-numberbox" data-options="min:0,precision:2" type="text" id="DelPackMon" name="DelPackMon" />&nbsp;元
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">商品条形码：<label>*</label></td>
                        <td colspan="3">
                            <input class="easyui-textbox" type="text" id="BarCode" name="BarCode" style="width:300px;" />
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">允许积分：</td>
                        <td>
                            <select class="easyui-combobox" id="DishesEnableInt" name="DishesEnableInt">
                                <option value="0">否</option>
                                <option value="1">参与平台积分</option>
                                <option value="2">参与商户积分</option>
                            </select>
                        </td>
                        <td class="fr">积分消费：</td>
                        <td>
                            <select class="easyui-combobox" id="DishesIsInt" name="DishesIsInt">
                                <option value="0">否</option>
                                <option value="1">使用平台积分</option>
                                <option value="2">使用商户积分</option>
                            </select>
                        </td>
                    </tr>
                    <tr style="color:#808080;" id="addnone">
                        <td class="fr">商品销量：</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="DishesVol" name="DishesVol" readonly="true" />
                        </td>
                        <td class="fr">总留言数：</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="DishesEvaTxt" name="DishesEvaTxt" readonly="true" />
                        </td>
                    </tr>
                    <tr style="color:#808080" id="addnone1">
                        <td class="fr">总评价数：</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="DishesEvaNun" name="DishesEvaNun" readonly="true" />
                        </td>
                        <td class="fr">总推荐数：</td>
                        <td>
                            <input class="easyui-textbox" type="text" id="DishesGood" name="DishesGood" readonly="true" />
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">商品描述：<label>*</label></td>
                        <td colspan="3">
                            <textarea rows="5" class="easyui-textarea" type="text" id="DishesTxt" name="DishesTxt" style="width: 500px"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">商品概述：<label>*</label></td>
                        <td colspan="3">
                            <textarea rows="3" style="width:400px;" id="DishesSummary_content" name="DishesSummary_content" class="easyui-validatebox" @*data-options="required:true,validType:'length[1,1000000]'" invalidMessage="最大长度不能超过1000000""*@></textarea>
                            <input type="hidden" name="DishesSummary" id="DishesSummary" />
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">商品参数：<label>*</label></td>
                        <td colspan="3">
                            <textarea rows="3" style="width:400px;" id="DishesParam_content" name="DishesParam_content" class="easyui-validatebox" @*data-options="required:true,validType:'length[1,1000000]'" invalidMessage="最大长度不能超过1000000""*@></textarea>
                            <input type="hidden" name="DishesParam" id="DishesParam" />
                        </td>
                    </tr>
                    <tr>
                        <td class="fr">备注信息：</td>
                        <td colspan="3">
                            <textarea rows="5" class="easyui-textarea" type="text" id="IntBZ" name="IntBZ" style="width: 500px"></textarea>
                        </td>
                    </tr>

                    <tr>
                        <td colspan="5" align="center" style="padding-top: 10px;">
                            <a href="javascript:void(0)" id="ok" class="easyui-linkbutton" iconcls="icon-ok" style="width: 60px; height: 20px" onclick="submitForm()">保存</a>
                        </td>
                    </tr>
                </table>
                <div id="fileName"></div>
            }
            <div id="dlg_progress" class="easyui-dialog" data-options="modal:true,iconCls:'icon-edit',closed:true" style="width: 600px; padding: 10px 50px 50px 10px;">
                <div id="progressNumber" class="easyui-progressbar" style="width: 400px;">
                </div>
            </div>
        </form>
    </div>
    <!--图片上传s-->
    <div id="UploadPic" class="easyui-dialog" style="width: 500px; padding: 30px" closed="true" resizable="true" modal="true" buttons="#dlg-buttons" align="center">
        <table>
            <tr>
                <td colspan="2" style="text-align: center;">
                    <label id="dishesID_pic"></label>
                    <div id="localImag">
                        <img id="div_img" alt="" onclick="" src="" width="200" height="200" />
                    </div>
                </td>
            </tr>
            <tr>
                <td>
                    <input id="fileToUpload" style="width: 224px; border: 1px solid #95B8E7" name="pic" multiple="multiple" onchange="fileSelected(this.id,'div_img');" type="file" />
                </td>
                <td>
                    <a id="uploadFile" style="display: none" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="uploadFile()">上传并导入</a>
                </td>
            </tr>
        </table>
    </div>

    <div onclick="shanchudiv(this)" style="position:fixed;margin:0 auto; left:50%; margin-left:-150px; margin-left:-300px;">
        <!--图片上传e-->
        <div id="xianshiPic" class="easyui-dialog" style="width:550px;height:450px;" closed="true" modal="true" title="图片" resizable="true">
            <div></div>
            <p id="tishiyu" align="center" style="margin: 0 auto;padding: 10px;">请在图片上选取要上传的部分</p>
            @*<div id="tp1Div" align="center" style="margin:auto;width:300px;padding: 10px;"><img id="tp1" style="border-style:solid; border-width:1px; border-color:#000;" src="~/Content/img/小象.jpg" /></div>*@
            @*<div align="center" style="padding: 10px;"><input type="file" /></div>*@
            <div id="picwenjian"></div>
            <div id="picwenjian1" style="display:none" align="center"><button onclick="quedPic()" style="margin:0px 20px;">确定</button>@*<button style="margin:0px 20px ;">关闭</button>*@</div>
        </div>
    </div>

    <!--轮播图和商品概述、参数图片上传-->
    <div id="upload_file_modal" class="easyui-dialog" style="width:900px;height:500px;" closed="true" modal="true" title="图片上传" resizable="true" closable="false">
        <div class="modal-content">
            <div class="modal-body">
                <div class="layui-upload">
                    <div style="margin-top:5px;">
                        <button type="button" class="layui-btn" style="margin-left:10px;" id="ChoosePicture">选择图片</button><span id="picture-name" style="margin-left:10px;color:red;"></span><button type="button" class="layui-btn" style="float:right;margin-right:10px;" onclick="UploadfileImg();">关闭</button>
                    </div>
                    <blockquote class="layui-elem-quote layui-quote-nm" style="margin: 5px;overflow:hidden;">
                        图片预览：
                        <div class="layui-upload-list">
                            <div class="padding-t-30" id="PictureListDemo">
                                <div style="clear:both"></div>
                            </div>
                        </div>
                    </blockquote>
                </div>
            </div>
        </div>
    </div>
</body>
</html>